package cn.e_eap.esite.web.form;

import java.beans.Encoder;
import java.io.File;
import java.net.URLEncoder;

import org.springframework.beans.propertyeditors.URLEditor;

public class FileBean {
	
	private String sn;

	public void setSn(String sn) {
		this.sn = sn;
	}

	public FileBean() {
	}
	
	public FileBean(File file) {
		this.file = file;
	}
	
	public String getSn(){
		return sn;
	}
	
	public FileBean (String file) {
		this.file = new File(file);
	}
	
	private File file;
	
	public boolean getDirectory() {
		return file.isDirectory();
	}
	
	public String getName() {
		return file.getName();
	}

	public String getPath() {
		
		return file.getPath();
	}

	public String getParent() {
		return file.getParent();
	}
 
	public long getSize() {
		if(file.isFile())
		return file.length();
		else if(file.isDirectory()){
			long s = 0;
			for(File f:file.listFiles()){
				s+=f.length();
			}
			return s;
		}
		return 0;
	}
 
	public long getTime() {
		return file.lastModified();
	}
 
	public File getFile() {
		return file;
	}

	public void setFile(File file) {
		this.file = file;
	}

	
}
